<?php

use yii\db\Migration;
use yii\db\Schema;

class m170614_061610_CREATE_TABLE_ORDER_PRICE_TYPE extends Migration
{
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

        // 订单附加费类型
        $this->createTable('order_price_type', [
            "id" =>           Schema::TYPE_PK,
            "product_id" =>   Schema::TYPE_INTEGER.   "(11)  NULL COMMENT '所属航线'",
            "name" =>         Schema::TYPE_STRING.    "(128) NULL COMMENT '附加费类型名称'",
            "desc" =>         Schema::TYPE_STRING.    "(255) NULL COMMENT '附加费类型描述'",
            "status" =>       Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>      Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" =>   Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>   Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);
    }

    public function down()
    {
        echo "m170614_061610_CREATE_TABLE_ORDER_PRICE_TYPE cannot be reverted.\n";

        $this->dropTable('order_price_type');
        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
